﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddEntityPage.aspx.cs" Inherits="Easy.Web.Pages.EntityPages.AddEntityPage" %>

<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
     <link href="/_css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="/_css/common.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" type="text/css" href="/_css/iconfont.css" />
    <script src="/_js/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="/_js/bootstrap.min.js" type="text/javascript"></script>
    <script src="/_js/json2.js" type="text/javascript"></script>
    <script  type="text/javascript">
        function addEntity(type) {
            var add = {};
            add["EntityName"] = $("#EntityName").val();
            add["EntityDisplayName"] = $("#EntityDisplayName").val();
            add["Desc"] = $("#Desc").val();

            $.ajax({
                url: "/Service/Entity/AddEntity.ashx",
                async: false,
                type: "post",
                dataType: "JSON",
                data: { "addEntity": JSON.stringify(add)
                },
                success: function (data, textStatus) {
                    if (data.Result == "0") {
                        if (type == 1) {
                            window.location = "EntityListPage.aspx";
                        } else if (type == 2) {
                            window.location = "AttributeListPage.aspx?Id=" + data.Remark;
                        } else if (type == 3) {
                            window.location = "AddEntityPage.aspx";
                        }
                    }
                    else {
                        alert(data.Remark);
                    }

                },
                error: function (data, textStatus) {
                    alert("错误");

                }

            });
        }
        function btn_return() {
            window.location = "EntityListPage.aspx";

        }
    </script>
    <style>
        .page-header{margin:15px;}
        .page-header+.btn-primary{margin:0px 15px 10px 5px;}
        .panel-heading{padding:3px 15px;height:40px;line-height:34px;}
    </style>
</head>
<body>
    <form id="form1" runat="server" >
    <div class="">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">
                    新建实体</h1>
                       <button type='button' style="float: right" id='Button1' class='btn btn-primary ng-binding'
                            onclick="btn_return();">
                            取消</button>
            </div>
            <!-- /.col-lg-12 -->
        </div>
        <!-- /.row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        <div class="form-group">
                            <label for="EntityDisplayName">
                                实体中文名</label>
                            <input type="text" class="form-control" id="EntityDisplayName" />
                        </div>
                        <div class="form-group">
                            <label for="EntityName">
                                实体英文名</label>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <%=Prefix%>_</div>
                                <input type="text" class="form-control" id="EntityName" />
                               
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="Desc">
                                备注</label>
                           <textarea class="form-control" rows="3" id="Desc"></textarea>
                        </div>
                       
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="button" class="btn btn-primary ng-binding" onclick="addEntity(1);">
                                    保存并关闭</button>
                                    <button type="button" class="btn btn-primary ng-binding" onclick="addEntity(2);">
                                    保存并打开</button>
                                    <button type="button" class="btn btn-primary ng-binding" onclick="addEntity(3);">
                                    保存并新建</button>
                            </div>
                        </div>
                    </div>
                    <!-- /.panel-body -->
                </div>
                <!-- /.panel -->
            </div>
        </div>
    </div>
    </form>
</body>
</html>
